<?php $this->headLink()
    ->appendStylesheet($this->css('basic.css')) ?>
<?php $this->headStyle()->captureStart()?>
#fieldset-mainGroup,#fieldset-subGroup{float:left}
#fieldset-mainGroup label,#fieldset-subGroup label{font-weight:bold; padding:10px;width:120px}

#showImg{height:350px;}
<?php $this->headStyle()->captureEnd()?>
<?php $this->headScript()
->appendFile($this->js('jquery-ui/ui/jquery.ui.dialog.js'))
->appendFile($this->js('jquery-ui/ui/jquery.ui.resizable.js'))
->appendFile($this->js('jquery-ui/ui/jquery.ui.draggable.js'))
->appendFile($this->js('plugins/jquery.form.js'))
->appendFile($this->js('plugins/jquery.bgiframe.js'))
->appendFile($this->js('jquery.simplemodal.js'))
->captureStart()?>
var year_name = <?php echo $this->year_name ?>;
$(document).ready(function(){
	<?php if ($this->form->logo_picture->getValue()):?>
	$("#logo_picture_img-label").append('&nbsp;  <a href="#" val="<?php echo $this->form->logo_picture->getValue()?>"><?php echo $this->translate('view')?></a>');
	<?php endif?>
	<?php if ($this->form->view_picture->getValue()):?>
	$("#view_picture_img-label").append('&nbsp;  <a href="#" val="<?php echo $this->form->view_picture->getValue()?>"><?php echo $this->translate('view')?></a>');
	<?php endif?>
	<?php if ($this->form->position_picture->getValue()):?>
	$("#position_picture_img-label").append('&nbsp;  <a href="#" val="<?php echo $this->form->position_picture->getValue()?>"><?php echo $this->translate('view')?></a>');
	<?php endif?>
	<?php if ($this->form->banner_picture->getValue()):?>
	$("#banner_picture_img-label").append('&nbsp;  <a href="#" val="<?php echo $this->form->banner_picture->getValue()?>"><?php echo $this->translate('view')?></a>');
	<?php endif?>
	$("#length-element").append('<span id="set_year" class="like_button">&nbsp; <a href="#"><?php echo $this->translate('Grade name set')?></a></span>');

	$('#fieldset-fileGroup a').click(function (e) {
		var ss = $(this).attr('val');
		$("#showImg").attr('src','<?php echo $this->route('getimg')?>/file/'+ss);

		$("#basicModalContent h1").html($(this).prev().html());
		e.preventDefault();
		$('#basicModalContent').modal();
	});

	 	$("#set_year").click(function(){
 		var id=$("#length").val();
 		var ss='';
 		jQuery.each(year_name[id],function(i,val){
 			ss += i+'. <input type="text" name="year_name['+i+']" value="'+val+'" /> <br />' ;
 		});
 		$("#con").html(ss);
 		$("#dialog").css('display','inline');
		$("#dialog").dialog({
 			modal: true,
	   }).bgiframe();
		$("#dialog").dialog("open");
 	});


 	var options = {
          success:       function(data){
        	$("#dialog").dialog("close");
        	var id=$("#length").val();

        	eval('var z='+data);

        	year_name[id]= z;
        	//console.dir(year_name);

        }
    };

    // bind form using 'ajaxForm'
    $('#set-length-Form').ajaxForm(options);
});
<?php $this->headScript()->captureEnd()?>


<div>

<div id="dialog" title="<?php echo $this->translate('Grade name set')?>" style="display:none;">
<div  style="padding:10px">
<form action="<?php echo $this->baseScript ?>/setyear" id="set-length-Form" method="post">
<div id="con"></div>

<br />
<?php echo  $this->form->id?>
<input type="submit" id="setBtn" value="<?php echo $this->translate('setup')?>" />
</form>
</div>
</div>

<form id="setForm" action="<?php echo  $this->route('set')?>" method="post" enctype="multipart/form-data">

<?php echo  $this->form->mainGroup?>
<?php echo  $this->form->subGroup?>
<?php echo  $this->form->fileGroup?>
<?php echo  $this->form->submit?>
<?php echo  $this->form->update_time?>
</form>

</div>
<div id="basicModalContent" style='text-align:center;display:none'>
	<h1></h1>
	<img id="showImg" src="" />
</div>

<div style="clear:both"></div>